<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-ms" lay-event="enter">进入</a>
<#--
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
-->
</script>




<script type="text/javascript" src="../layui/layui.js"></script>
<script src="../lib/js/utils.js"></script>

<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            , url: webPath + '/room/list'
             ,title: '用户数据表'
            , where: {id: GetQueryString("id")}
            ,cols: [[
                {field: 'roomId', title: '房间号'}
                , {field: 'roomName', title: '房间名'}
                , {field: 'createDate', title: '创建时间'}
                , {field: 'userName', title: '创建人'}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
            ,page: true
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(data)
            location.href="/canvasPage?id="+data.roomId;
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>

</body>
</html>
